package com.example.demo.leetcode.classics150;

import java.util.Locale;

/**
 * ******************************************************
 *
 * @author liugh9
 * @version 1.0
 * @classname _25验证回文串
 * @description
 * @date 2023/07/16 8:19
 * <p>
 * ******************************************************
 */
public class _25验证回文串 {
    public boolean isPalindrome(String s) {
        s = s.toLowerCase();
        int left = 0;
        int right = s.length() - 1;
        while (left <= right) {
            while (left < right && !Character.isLetterOrDigit(s.charAt(left))) {
                left++;
            }
            while (left < right && !Character.isLetterOrDigit(s.charAt(right))) {
                right--;
            }
            if (s.charAt(left) != s.charAt(right)) {
                return false;
            }
            left++;
            right--;

        }
        return true;
    }

    public static void main(String[] args) {
        _25验证回文串 s = new _25验证回文串();
        s.isPalindrome("ab_a");
    }
}
